package com.example.ffepeg.gorithm;

public class TestFiles {

    public static String getFileExtension(String fileName) {
        int lastDotIndex = fileName.lastIndexOf('.');
        if (lastDotIndex == -1) {
            return "";
        }
        return fileName.substring(lastDotIndex+1);
    }
    private static boolean judgeExtensions(String img){
        String extension = getFileExtension(img);
        if (extension.equals("png") || extension.equals("jpeg") || extension.equals("jpg")){
            return true;
        }else {
            return false;
        }
    }

    public static void main(String[] args) {
      /*  String img = "C:\\Users\\Administrator\\Desktop\\260.png";
        boolean b = judgeExtensions(img);
        System.out.println(b);*/

        int width = 1280;
        int height = 720;
        if (isAspectRatioValid(width, height)) {
            System.out.println("长宽比符合要求");
        } else {
            System.out.println("长宽比不符合要求");
        }
    }

    // 检查给定的宽度和高度的长宽比是否在1:3到3:1之间
    public static boolean isAspectRatioValid(int width, int height) {
        double ratio = (double) Math.max(width, height) / Math.min(width, height);
        return ratio >= 1.0/3 && ratio <= 3.0;
    }

    public static String getSystem101(){
        String os = System.getProperty("os.name").toLowerCase();
        String  system = "";
        if (os.contains("win")) {
            system = "Windows";
        } else if (os.contains("nix") || os.contains("nux") || os.contains("aix")) {
            system = "Linux";
        } else {
            system = "不清楚";
        }
        return system;
    }

}
